package cc.langk.sms.entity;

import cc.langk.sms.base.BaseEntity;
import cc.langk.sms.util.tencent.SmsMultiSenderResult;
import cc.langk.sms.util.tencent.SmsSingleSenderResult;

import java.util.Date;
import java.util.List;

/**
 * 短信发送历史
 */
public class TencentSmsResult extends BaseEntity {

    private SmsSingleSenderResult smsSingleSenderResult;
    private SmsMultiSenderResult smsMultiSenderResult;

    /**
     * 0表示成功，非0表示失败，失败后没有detail列表信息
     */
    private int result;

    /**
     * result非0时的具体错误信息
     */
    private String errmsg;
    /**
     * 用户的session内容，腾讯server回包中会原样返回
     */
    private String ext;
    private List<TencentSmsItemResult> detail;

    public int getResult() {
        return result;
    }

    public void setResult(int result) {
        this.result = result;
    }

    public String getErrmsg() {
        return errmsg;
    }

    public void setErrmsg(String errmsg) {
        this.errmsg = errmsg;
    }

    public String getExt() {
        return ext;
    }

    public void setExt(String ext) {
        this.ext = ext;
    }

    public List<TencentSmsItemResult> getDetail() {
        return detail;
    }

    public void setDetail(List<TencentSmsItemResult> detail) {
        this.detail = detail;
    }

    public SmsSingleSenderResult getSmsSingleSenderResult() {
        return smsSingleSenderResult;
    }

    public void setSmsSingleSenderResult(SmsSingleSenderResult smsSingleSenderResult) {
        this.smsSingleSenderResult = smsSingleSenderResult;
    }

    public SmsMultiSenderResult getSmsMultiSenderResult() {
        return smsMultiSenderResult;
    }

    public void setSmsMultiSenderResult(SmsMultiSenderResult smsMultiSenderResult) {
        this.smsMultiSenderResult = smsMultiSenderResult;
    }

    public boolean checkSuccess() {
        if (this.getSmsMultiSenderResult()!=null){
            return this.getSmsMultiSenderResult().result==0;
        }else if(this.getSmsSingleSenderResult()!=null){
            return this.getSmsSingleSenderResult().result==0;
        }else {
            return this.result==0;
        }
    }
}
